window.addEventListener('load', function() {
    //下拉栏触发js
    var dropdown_layer = document.querySelectorAll('.dropdown-layer');
    var div_icon = document.querySelectorAll('.div-icon');
    var iconfont_rotate = document.querySelectorAll('.iconfont-r');
    // 封装函数，再调用，节省大量代码
    function mmove(ele, i) {
        ele[i].addEventListener('mousemove', function() {
            dropdown_layer[i].className = 'dd dropdown-layer dropdown-layer-hover';
            iconfont_rotate[i].className = 'iconfont iconfont-r iconfont-rotate';
        });
    }

    function mout(ele, i) {
        ele[i].addEventListener('mouseout', function() {
            dropdown_layer[i].className = 'dd dropdown-layer';
            iconfont_rotate[i].className = 'iconfont iconfont-r';
        });
    }

    for (var z = 0; z < dropdown_layer.length; z++) {
        mmove(div_icon, z);
        mmove(dropdown_layer, z);
        mout(div_icon, z);
        mout(dropdown_layer, z);
    }

    //搜索框优化js
    var search = document.getElementById('search');
    search.addEventListener('focus', function() {
        search.style.color = '#202020';
    });
    search.addEventListener('blur', function() {
        search.style.color = '#8b8b8b';
    });
})